﻿begin transaction

declare @weightId int
declare @bodyFatId int
declare @bmiId int
declare @waistId int
declare @chestId int
declare @armsId int
declare @thighsId int
declare @heightid int
select @weightId = MeasurementTypeId from MeasurementType where Description='Weight'
select @bodyFatId = MeasurementTypeId from MeasurementType where Description='Body Fat %'
select @bmiId = MeasurementTypeId from MeasurementType where Description='BMI'
select @waistId = MeasurementTypeId from MeasurementType where Description='Waist'
select @chestId = MeasurementTypeId from MeasurementType where Description='Chest'
select @armsId = MeasurementTypeId from MeasurementType where Description='Arms'
select @thighsId = MeasurementTypeId from MeasurementType where Description='Thighs'
select @heightid = MeasurementTypeId from MeasurementType where Description='Height'

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @weightId, BodyId, Weight from Body where Weight is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @bodyFatId, BodyId, BodyFat from Body where BodyFat is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @bmiId, BodyId, BMI from Body where BMI is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @waistId, BodyId, Waist from Body where Waist is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @chestId, BodyId, Chest from Body where Chest is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @armsId, BodyId, Arms from Body where Arms is not null

insert into Measurement (MeasurementTypeId,  BodyId, Value)
select @thighsId, BodyId, Thighs from Body where Thighs is not null 

insert into Measurement (MeasurementTypeId, BodyId, Value)
select @heightId, BodyId, Height from Body where Height is not null

commit transaction